#include<iostream>
#include<string>
#include<fstream>
using namespace std;

#define ERROR 0

typedef struct LNode
{
	int data;
	struct LNode *next;
}LNode, *List;

int n, m;
char st = 'A';

void InitList(List &L)
{
	L = new LNode;
	L->next = NULL;
}
void ListInput(List &L, int n)
{
	
    /*************************Begin*********************************/
    LNode *T = L;
    while(n--)
    {
        LNode *p = new LNode;
        cin >> p->data;
        p->next = T->next;
        T->next = p;
        T = p;
    }
    /**********************End************************************/
}
bool LocateElem(List L, int e)
{
	/*************************Begin*********************************/
    LNode *p = L;
    while(p)
    {
        if(p->data == e)
            return true;
        p = p->next;
    }
    return false;
    /**********************End************************************/
}
void ListInsert(List &L, int e)
{
	/*************************Begin*********************************/
    LNode *p = new LNode;
    p->data = e;
    p->next = L->next;
    L->next = p;
    /**********************End************************************/
}
void ListOutput(List L)
{
	List p = L->next;
	while(p != NULL)
	{
		cout << p->data << " ";
		p = p->next;
	}
	cout << endl;
}
void unionList(List &LA, List LB)
{
	/*************************Begin*********************************/
    LNode *p = LB->next;
    while(p)
    {
        if(!LocateElem(LA, p->data))
            ListInsert(LA, p->data);
        p = p->next;

    }
    /**********************End************************************/
}
int main()
{
	List LA, LB;
	
	InitList(LA);
	InitList(LB);
	
	scanf("%d", &n);
	scanf("%d", &m);
	
	ListInput(LA, n);
	ListInput(LB, m);
	
	unionList(LA, LB);
	
	ListOutput(LA);
	
	return 0;
}